const {Homework} = require('../../model/homework');
const formidable = require('formidable');
const path = require('path');

module.exports = async (req, res) => {
    const form = new formidable.IncomingForm();
    form.uploadDir = path.join(__dirname, '../', '../', 'public', 'homework');
    form.keepExtensions = true;
    form.parse(req, (err, fields, files) => {
        if (err) {
            res.redirect('/home/homework');
        } else {
            let homework = await Homework.create(req.body);
        }
    });
}